/* 替换title字符为span */
const h1 = document.getElementsByClassName("title")[0];
const title = h1.innerText;

h1.innerText = "";
for (let i = 0; i < title.length; i++) {
	let span = document.createElement("span");
	span.innerText = title[i];
	span.style.animationDelay = `${i * 0.1}s`;
	span.addEventListener("animationend", function () {
		this.classList.remove("text");
	});
	h1.appendChild(span);
}

function AddAnimation() {
	const children = Array.from(h1.children);

	children.forEach((element) => {
		element.classList.remove("text");
		element.classList.add("text");
	});
}

setInterval(AddAnimation, 2000);
